package com.srxz.mobilepharmacy.util;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

import java.io.IOException;
import java.text.DecimalFormat;

/**
 * @ClassName: CustomDoubleIntSerialize
 * @author: wgchao
 * @createTime: 2019/1/10 3:20 PM
 * @Description: double类型 保留4位小数
 */
public class CustomDoubleIntSerialize extends JsonSerializer<Double> {
    private DecimalFormat df = new DecimalFormat("###0.0000");
    @Override
    public void serialize(Double value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
        gen.writeString(df.format(value));
    }
}
